package com.weixin.paleituo.factory;

import android.support.v4.app.Fragment;

import com.weixin.paleituo.fragment.BrokerageMyIntegralFragment;
import com.weixin.paleituo.fragment.BrokerageMyLowberFragment;
import com.weixin.paleituo.fragment.BrokerageSharFragment;
import com.weixin.paleituo.util.LogUtils;

import java.util.HashMap;

/**
 * Author yichao
 * Time  2017/11/30 9:36
 * Dest  全民经纪人fragment的工厂
 */

public class BrokerageFragmentFactory {
    public static String TAG="BrokerageFragmentFactory";
    private static final int SHARE_FRAGMENT = 0;
    private static final int MYLOWBER_FRAGMENT = 1;
    private static final int MYINTEGRAL_FRAGMENT = 2;
    private static HashMap<Integer,Fragment> mMap=new HashMap();


    public static Fragment getFragment(int index) {
        Fragment fragment=null;
        if (mMap.containsKey(index)){
            fragment=   mMap.get(index);
            LogUtils.i(TAG,"复用"+index);
        }else {
            switch (index) {
                case SHARE_FRAGMENT:
                    fragment = new BrokerageSharFragment();
                    break;
                case MYLOWBER_FRAGMENT:
                    fragment = new BrokerageMyLowberFragment();
                    break;
                case MYINTEGRAL_FRAGMENT:
                    fragment = new BrokerageMyIntegralFragment();
                    break;

            }
            LogUtils.i(TAG,"新建"+index);
            mMap.put(index,fragment);

        }


        return fragment;

    }


}
